﻿using System;
using System.Collections.Generic;
using System.Text;
using Tsanie.DmPoster.Event;

namespace Tsanie.DmPoster.Models {
    /// <summary>
    /// 弹幕基类
    /// </summary>
    public abstract class CommentBase {
        private static int _id = 0;

        /// <summary>当属性修改时触发</summary>
        internal PropertyHandler _propertyChanged;

        private int id;
        /// <summary>获取弹幕ID</summary>
        internal virtual int Id { get { return this.id; } }
        /// <summary>弹幕内容</summary>
        public virtual string Message { get; set; }
        /// <summary>弹幕颜色</summary>
        public virtual int Color { get; set; }
        /// <summary>弹幕字号大小</summary>
        public virtual int Fontsize { get; set; }
        /// <summary>弹幕播放时间</summary>
        public virtual float PlayTime { get; set; }
        /// <summary>弹幕创建时间</summary>
        public virtual DateTime Date { get; set; }

        public CommentBase() {
            this.id = _id++;
            this.Date = DateTime.Now;
        }

        public static int Compare(CommentBase comm1, CommentBase comm2) {
            int rtn = comm1.PlayTime.CompareTo(comm2.PlayTime);
            if (rtn == 0) {
                rtn = comm1.Date.CompareTo(comm2.Date);
            }
            return rtn;
        }
    }
}
